package com.bdrm.controller.admin;

import com.bdrm.entity.Flavor;
import com.bdrm.result.Result;
import com.bdrm.service.FlavorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "口味接口")
@RequestMapping("/admin/flavor")
public class FlavorController {

    @Autowired
    private FlavorService flavorService;

    @ApiOperation("添加口味")
    @PostMapping("/save")
    public Result save(Flavor flavor) {
        flavorService.save(flavor);
        return Result.success();
    }

    @ApiOperation("查询所有口味")
    @PostMapping("/list")
    public Result list(){
        List<Flavor> list = flavorService.list();
        return Result.success(list);
    }

    @ApiOperation("修改口味")
    @PutMapping("update")
    public Result update(Flavor flavor){
        flavorService.update(flavor);
        return Result.success();
    }
    @ApiOperation("删除口味")
    @DeleteMapping("{id}")
    public Result delete(@PathVariable Long id){
        flavorService.delete(id);
        return Result.success();
    }
}
